﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WorkItemAnalyser.Core.Parsers;

namespace WorkItemAnalyser.Test.ParserTests
{
    [TestClass]
    public class TextFieldAssertionParserTests
    {
        [TestMethod]
        public void TextFieldAssertionParser_ParseAssertion_ShouldReturnNullForEmptyString()
        {
            //Arrange 
            var parser = new TextFieldAssertionParser();

            //Act
            var assertion = parser.ParseAssertion("");

            //Assert
            Assert.IsNull(assertion);
        }
        
        [TestMethod]
        public void TextFieldAssertionParser_ParseAssertion_ShouldReturnNullForInvalidString()
        {
            //Arrange 
            var parser = new TextFieldAssertionParser();

            //Act
            var assertion = parser.ParseAssertion("some invalid rule text");

            //Assert
            Assert.IsNull(assertion);
        }

        [TestMethod]
        public void TextFieldAssertionParser_ParseAssertion_ShouldReturnNullForPartiallyValidString()
        {
            //Arrange 
            var parser = new TextFieldAssertionParser();

            //Act
            var assertion = parser.ParseAssertion("field should blah blah");

            //Assert
            Assert.IsNull(assertion);
        }

        [TestMethod]
        public void TextFieldAssertionParser_ParseAssertion_ShouldReturnAssertionForValidFullString()
        {
            //Arrange 
            var parser = new TextFieldAssertionParser();

            //Act 
            var assertion = parser.ParseAssertion("must have iteration path of //WICSA/Iteration 1");

            //Assert
            Assert.IsNotNull(assertion);
        }

        [TestMethod]
        public void TextFieldAssertionParser_ParseAssertion_ShouldReturnAssertionForValidStatusString()
        {
            //Arrange 
            var parser = new TextFieldAssertionParser();

            //Act 
            var assertion = parser.ParseAssertion("must be closed");

            //Assert
            Assert.IsNotNull(assertion);
        }
    }
}
